import Vue from "vue";
import Vuex from "vuex";

Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    msgCount: localStorage.getItem("msgCount") || 0,
    showComplaint: false,
    isColor: "#5c90dc",
    isJumap: false,
    user_name: "",
    user_type: "",
    colors: [
      {
        bgColor: "#E9EFEF",
        wordColor: "#60807D",
        lineColor: "#B6C4C3",
        level: "青铜会员"
      },
      {
        bgColor: "#F7F7F7",
        wordColor: "#A3AAB0",
        lineColor: "#D2D9E0",
        level: "白银会员"
      },
      {
        bgColor: "#FFF8DE",
        wordColor: "#CEAB21",
        lineColor: "#D3CAB2",
        level: "黄金会员"
      },
      {
        bgColor: "#EDFAFF",
        wordColor: "#59B0E6",
        lineColor: "#BBD0DB",
        level: "铂金会员"
      },
      {
        bgColor: "#F2F5FF",
        wordColor: "#284EB6",
        lineColor: "#C1CBEF",
        level: "钻石会员"
      },
      {
        bgColor: "#FDF7FF",
        wordColor: "#A877C6",
        lineColor: "#DBC6E8",
        level: "钻石Ⅰ会员"
      },
      {
        bgColor: "#F8F2FF",
        wordColor: "#78439F",
        lineColor: "#958AC3",
        level: "钻石Ⅱ会员"
      },
      {
        bgColor: "#F4F2F2",
        wordColor: "#8D4581",
        lineColor: "#907B8C",
        level: "钻石Ⅲ会员"
      },
      {
        bgColor: "#F4F2F2",
        wordColor: "#502E30",
        lineColor: "#795D5E",
        level: "王者会员"
      }
    ]
  },
  mutations: {
    setShowComplaint(state, payload) {
      state.showComplaint = payload;
      
    },
    setMsgCount(state, payload) {
      // console.log('msgCountmsgCountmsgCountmsgCountmsgCountmsgCount',payload)
      state.msgCount = payload;
      localStorage.setItem("msgCount", payload);
    },
    edit(state, payload) {
      state.isColor = payload;
    },
    hdJumap(state, payload) {
      state.isJumap = payload;
    },
    login(state, payload) {
      payload = JSON.parse(JSON.stringify(payload));
      console.log("payloadpayloadpayload", payload);
      state.user_name = payload.user_name;
      if (payload.user_type) {
        state.user_type = payload.user_type;
      }
    },

    unLogin(state) {
      state.user_name = "";
      state.user_type = "";
    }
  },
  actions: {},
  modules: {}
});
